package com.pikaqiu.serviceribbon.controller;

import com.pikaqiu.serviceribbon.api.UserClient;
import com.pikaqiu.serviceribbon.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    HelloService helloService;

    @Autowired
    private UserClient userClient;

    @RequestMapping("/hi")
    @ResponseBody
    public String hi(@RequestParam String name){
        System.out.println("this is ribbon");
        return helloService.hiService(name);
    }

    @RequestMapping("/getUserInfo")
    @ResponseBody
    public String getUserInfo(){
        String info = userClient.getUserInfo();
        System.out.println(info);
        return info;
    }

    @ResponseBody
    @RequestMapping("/hello")
    public String hi(){
        String name = "皮卡丘";
        String hi = userClient.hi(name);
        return hi;

    }

}